package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.wx.user.UserIndexData;
import com.cskaoyan.service.wx.WxUserIndexService;
import com.cskaoyan.util.UserIdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: WxUserController
 * Description:
 * date: 2022/6/7 22:41
 *
 * @author bruce
 * @since JDK 8
 */
@RestController
@RequestMapping("wx/user")
public class WxUserController {

    @Autowired
    WxUserIndexService userIndexService;

    @RequestMapping("index")
    public BaseRespVo UserIndex() {
        Integer userIdFromSubject = UserIdUtil.getUserIdFromSubject();
        if (userIdFromSubject == -1) {
            return BaseRespVo.unlogin();
        }
        UserIndexData indexData = userIndexService.query(userIdFromSubject);
        return BaseRespVo.ok(indexData);
    }
}
